package com.example.helloword

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.example.helloword.databinding.ActivityEditInfoBinding

class EditInfoActivity : AppCompatActivity() {
    private lateinit var binding: ActivityEditInfoBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityEditInfoBinding.inflate(layoutInflater)
        setContentView(binding.root)

        binding.etName.setText(intent.getStringExtra("name"))
        binding.etGender.setText(intent.getStringExtra("gender"))
        binding.etPhone.setText(intent.getStringExtra("phone"))

        binding.btnSave.setOnClickListener {
            val data = Intent()
            data.putExtra("name", binding.etName.text.toString())
            data.putExtra("gender", binding.etGender.text.toString())
            data.putExtra("phone", binding.etPhone.text.toString())
            setResult(Activity.RESULT_OK, data)
            finish()
        }
    }
}
